* models_appendix.do
* Outputs: Turnout model, t_turnout.tex
* Dependencies: master_elec.dta

not a command but stops execution of the code if whole do file is ran accidentally

set more off

* load data
cap cd ""
cap use "master_elec.dta", clear

*Create correct time - var
gen election_date2 = date(election_date, "YMD")
format election_date2 %td

* But not a useful time variable because it doesn't allow lags
* We need a temporal count variable

*Creat year
gen year = election_year
* Create year squared
gen year2 = year^2

* Create compulsory voting dummy
gen comp_vote_dummy = 0
replace comp_vote_dummy = 1 if compulsory_voting == "Yes"
replace comp_vote_dummy = . if compulsory_voting == "NA"

***NB (!): Two types of elections in the data: EP and nat. parl

** Paper

* Parliamentary elections only for now
*Drop EP results
keep if election_type=="parliament"

xtset country_id election_count

* Turnout ----------------------------------------------------------------------

eststo clear
eststo to: xtreg turnout year, fe vce(robust)

esttab to ///
	using "tables/t_turnout.tex" ///
	, se be(2) r2 obslast nocon nomtitles star(* 0.05 ** 0.01) booktabs ///
	coeflabels(turnout "Turnout") replace
